﻿<UserControl x:Class="SkypeStudio.Controls.Views.SendMessage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:SkypeStudio.Controls.Views"
             mc:Ignorable="d"  d:DesignHeight="300" d:DesignWidth="300"
            >

    <Grid  Grid.Row="1" >
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="Auto" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Button  Grid.Column="0"  Content="Back to Chat List" Command="{Binding BackToChatListCommand}" Visibility="{Binding IsChatMessageActive}"></Button>
            <TextBlock Grid.Column="1"  x:Name="txtContactName" Text="{Binding ChatSource.MembersName}" FontWeight="Bold"/>
        </Grid>
      
        <ListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" ItemsSource="{Binding ChatMessages}" 
                  local:ListViewExtenders.AutoScrollToCurrentItem="True">
            <!--<ListView.View>
                <GridView>
                    <GridViewColumn Width="Auto"   DisplayMemberBinding="{Binding User.Name}"/>
                    <GridViewColumn   Width="Auto" DisplayMemberBinding="{Binding Message}"  />
                </GridView>
            </ListView.View>-->
            <ListView.ItemTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Vertical">
                        <TextBlock Text="{Binding User.Name}" Foreground="Gray" FontWeight="Bold" Margin="5"></TextBlock>
                        <TextBlock Text="{Binding Message}" MaxWidth="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=ListView, AncestorLevel=1}, Path=ActualWidth}" 
                                   Margin="5, 0, 5, 5" TextWrapping="Wrap"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>

        <TextBox Grid.Row="2" Grid.Column="0"  AllowDrop="True" Margin="3" Grid.RowSpan="2" 
                 Text="{Binding SendText, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                 TextWrapping="Wrap" MaxLines ="5">
            <TextBox.InputBindings>
                <KeyBinding Gesture="Enter" Modifiers="" Command="{Binding SendMessageCommand}" CommandParameter="{Binding}"/>
            </TextBox.InputBindings>
        </TextBox>
        <Button Grid.Row="2" Grid.Column="1" Width="56"  Height="56"  Margin="3" Command="{ Binding SendMessageCommand }" Grid.RowSpan="2">
            <Image  Source="/SkypeStudio;component/Images/Message_start_GreenStart_56x56_s1.png" />
        </Button>
    </Grid>

</UserControl>
